package com.binc.testspring.controller;

import com.binc.testspring.service.IExportService;
import com.binc.testspring.vo.IdVo;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * easyExcel导出的简单示例
 */
@Api(tags = "easyExcel")
@Slf4j
@RestController
@RequestMapping("/easyExcel")
public class EasyExcelExportController {

    @Autowired
    IExportService exportService;

    @PostMapping("/export")
    // @ApiOperation(value = "导出", notes = "")
    public void transFlowlistExport(HttpServletResponse response, @RequestBody IdVo idVo) throws Exception {
        long start = System.currentTimeMillis();
        exportService.export(response, idVo);
        long end = System.currentTimeMillis();
        log.info(String.format("导出表 between tm is %s", end - start));
    }
}
